#ifndef __INTER_PROCESS_COMMUNICATION__
#define __INTER_PROCESS_COMMUNICATION__

#include <atomic>
#include <map>
#include "IUtility.h"
#include "IIntProCom.h"
#include "IContainer.h"
#include "IThreadPoolManager.h"
#include "ISysResources.h"

class CInterProcessCommunication: public virtual IInterProcessCommunication
{
INIT_CLASS_SINGLETON(CInterProcessCommunication)
public:    
    const bool Init(const void * pvdPara, char * pszMsgTxt, int iMsgTxtSize);    
	const bool AfterInit();
	void CallBakFun(IData * ptrMsgObj);
	const unsigned long ProcessID();
	void SetProcessId(unsigned long ulProcessID);
    void SetCallFunc(PCallBakFun ptrCallBakFun, void * ptrArg);
	void AddhData(IData * ptrTask);
    bool SendAsynTask(IData * ptrTask);
    bool SendAsynTask(unsigned long ulProcessId, IData * ptrTask);
    bool SendAsynTask(const char * pszAppName, IData * ptrTask);

	bool SendSyncTask(IData * ptrTask, IData ** ptrReslut, int iTimeOut = 60);
	bool SendSyncTask(unsigned long ulProcessId, IData * ptrTask, IData ** ptrReslut, int iTimeOut = 60);
	bool SendSyncTask(const char * pszAppName, IData * ptrTask, IData ** ptrReslut, int iTimeOut = 60);	

	const char * SendQueueName();
	const char * ReceiveQueueName();
	bool InitThreadPool(int iType);
private:
	shared_ptr<ILock> m_ptrLock;
	map<string, IData *> m_mpSyncFinally;
    PCallBakFun m_ptrPCallBakFun;
    void * m_ptrArg;
    string m_strProQueueName;
	atomic<unsigned long> m_ulProcessID;
	atomic<unsigned long long> m_ullSeq;
private:    
	IData * GetData(const char * pszMsgFlg);
	bool SendTask(unsigned long ulProcessId, IData * ptrTask, char ** pszTigName, int iFlg = 0);
};


#endif//__INTER_PROCESS_COMMUNICATION__